package top.humbleyuan.sword.util;

import top.humbleyuan.util.BigDecimalUtil;

/**
 * @Author HumbleYuan
 * @Date 2019/12/19 15:29
 * @Des
 */
public class MyUtil {

    private static class Instance {
        private static final MyUtil myUtil = new MyUtil();
    }

    public static MyUtil getMyUtil() {
        return Instance.myUtil;
    }

    /**
     * 生成长度为len,且每个数的范围都在0-(len-1)范围内
     * @param len
     * @return
     */
    public int[] formArray(int len) {
        int[] arr = new int[len];

        for (int i = 0; i < len; i++) {
            int ran = BigDecimalUtil.getInt(Math.random() * len);
            arr[i] = ran == len ? ran - 1 : ran ;
        }
        return arr;
    }

}
